let start = document.querySelector(".start");
let body = document.querySelector("body");
let mine = document.querySelector(".mine")

let username = document.querySelector("#name");
let phone = document.querySelector("#phone");
let card = document.querySelector("#card");
// window.location.href = "../预约页/order.html";
$(document).ready(function() {
    $(start).click(() => {
        $.ajax({
            url: "http://newshopapi.0melon0.cn/api/f_user/register",
            data: {
                // "name": "yu",
                // "phone": "13612345678",
                // "card": 440882111,
                name: username.value,
                phone: phone.value,
                card: card.value,
            },
            type: "POST",
            dataType: "json",
            success: function(data) {
                console.log(data);
                console.log(data.result.token);
                sessionStorage.setItem("token", `${data.result.token}`);
                sessionStorage.setItem("name", `${username.value}`);


                if (data.errorCode == 0) {
                    $("#nickname").val(mylogin.nickname);
                } else {
                    window.location.href = "./预约页/order.html";
                    $("#nickname").val("用户");
                }
            },
            error: function(e) {
                console.log(e.status);
                console.log(e.responseText);
            }

        })

    })
});

mine.addEventListener("click", () => {
    if (sessionStorage.getItem("token")) {
        window.location.href = "./查看预约页C/view.html"
    }
})